package com.ciei.dpagm.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.ciei.dpagm.util.EnumUtil;

/**
 * 数据类型枚举
 * @author wy
 * @date 2023/03/09
 */
public enum DataTypeEnum {
    /**
     * String
     */
    STRING(1,"String"),
    /**
     * Integer
     */
    INTEGER(2, "Integer"),
    /**
     * Char
     */
    CHAR(3, "Char"),
    /**
     * Double
     */
    DOUBLE(4, "Double"),
    /**
     * Long
     */
    LONG(5, "Long"),
    /**
     * Float
     */
    FLOAT(6, "Float"),
    /**
     * BigDecimal
     */
    BIG_DECIMAL(7, "BigDecimal"),
    /**
     * Boolean
     * */
    BOOLEAN(8,"Boolean"),
    /**
     * Date
     * */
    DATE(9,"Date"),
    /**
     * JSONObject
     */
    JSON_OBJECT(15,"JSONObject"),
    /**
     * JSONArray
     */
    JSON_ARRAY(16,"JSONArray");

    /**
     * 类型ID
     */
    @EnumValue
    private Integer typeId;
    /**
     * 类型名称
     */
    private String typeName;

    public static DataTypeEnum typeValueOf(Integer typeId) {
        return EnumUtil.getEnumObject(DataTypeEnum.class, e -> e.getTypeId().equals(typeId)).orElse(null);
    }

    public static DataTypeEnum typeNameOf(String typeName) {
        return EnumUtil.getEnumObject(DataTypeEnum.class, e -> e.getTypeName().equals(typeName)).orElse(null);
    }

    DataTypeEnum(Integer typeId, String typeName) {
        this.typeId = typeId;
        this.typeName = typeName;
    }

    public Integer getTypeId() {
        return typeId;
    }

    public String getTypeName() {
        return typeName;
    }
}
